package com.test.demo;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * usermapper
 * 
 * @author kk
 *
 */
@Mapper
public interface UserMapper {

	@Select("Select * from USER WHERE NAME=#{name}")
	User findByName(@Param("name") String name);
	
	@Insert("insert into USER(name,age) values(#{name},#{age})")
	int insert(@Param("name") String name,@Param("age") Integer age);
	
	@Results({@Result(property="name",column="name"),
		@Result(property="age",column="age")})
	@Select("Select name,age from user")
	List<User> findAll();
	
	@Update("update user set age=#{age} where name=#{name}")
	void update(User user);
	
	@Delete("delete from user where id=#{id}")
	void delete(long id);
	
	 @Insert("INSERT INTO user(name, age) VALUES(#{name}, #{age})")
	 int insertByUser(User user);

	 @Insert("INSERT INTO user(name, age) VALUES(#{name,jdbcType=VARCHAR}, #{age,jdbcType=INTEGER})")
	 int insertByMap(Map<String, Object> map);
	
	
}
